/*
 * MVCFinCobranza.java
 *
 * Created on 13 de noviembre de 2008, 08:08 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */
package com.nextel.project.cobranza.mvc;


import com.nextel.project.util.MVCBasic;
import com.nextel.project.Configuracion;
import com.nextel.project.cobranza.ControlCobranza;
import com.nextel.ui.OImage;
import com.nextel.ui.OLabel;
import com.nextel.ui.OSoftKey;
import com.nextel.ui.OUILook;
import pe.com.nextel.idioma.IdiomaManager;
import pe.com.nextel.main.MVCAction;
import pe.com.nextel.util.math.MathUtil;

/**
 *
 * @author eespinoza
 */
public class MVCFinCobranza extends MVCAction {

    private OLabel str;
    
    private OSoftKey cmdFin, cmdAtras;
    private boolean flagForm; // para que no presione dos veces al momento de buscar
    
     protected void createView()  {

        cmdFin = new OSoftKey(IdiomaManager.getInstance().getMensaje(IdiomaManager.JAVA_SI));//"Si"
        cmdAtras = new OSoftKey(IdiomaManager.getInstance().getMensaje(IdiomaManager.JAVA_NO));//"No"

        formulario.setTitle(IdiomaManager.getInstance().getMensaje(IdiomaManager.JAVA_COBRANZA), OUILook.PLAIN_SMALL_TITLE);//"Cobranza"

        formulario.addSoftKey(cmdFin);
        formulario.addSoftKey(cmdAtras);

    }
  
 protected void createItems() {
     StringBuffer stf = new StringBuffer();
        
        stf.append(IdiomaManager.getInstance().getMensaje(IdiomaManager.JAVA_FINALIZAR_COBRANZA)).append('\n');//"\u00BFEst\u00E1 seguro de Grabar?"
        stf.append('\n');
        if (ControlCobranza.getInstance().currentCobranza != null) {
            stf.append(ControlCobranza.getInstance().currentCobranza.getNumeroDocumento()).append('\n');
        }
     
        stf.append("FP: ").append(ControlCobranza.getInstance().currentPago.getFPagoLabel()).append('\n');
        stf.append("MN: " + Configuracion.Moneda + " ").append(Configuracion.CambiarSimbolo(MathUtil.setScale(ControlCobranza.getInstance().currentPago.getMontoPago(), Configuracion.DECIMAL_PRESENTACION))).append('\n');
        
              
        str = new OLabel(stf.toString(),OUILook.PLAIN_SMALL_TEXT);
        
       try{
        formulario.add(new OImage("/res/confirmacion.PNG"));
        formulario.add(str);
        flagForm = true;
                
       }catch(Exception ex){
           
       }
     
 }
    

  public void performAction(OSoftKey c) {
        if (flagForm) {
            flagForm = false;

            if (c == cmdFin) {
                ControlCobranza.getInstance().grabarPago( );
            } else if (c == cmdAtras) {
                ControlCobranza.getInstance().setCurrent(ControlCobranza.getInstance().mvcTipoPago);
            }
            destroy();
        }
    }
}
